﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using ITAP.ShprossesBuilder.Modelling.Components;
using Atechnology.glassCAD.Shapes;

namespace ITAP.ShprossesBuilder.Editor
{
    public partial class SelectShapesForm : Form
    {
        private ModelCellRepository cellRepository;

        public ModelCellRepository CellRepository
        {
            get { return cellRepository; }
        }
        public SelectShapesForm()
        {
            InitializeComponent();
            cellRepository = new ModelCellRepository();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
        private int modelCounter = 0;
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            AddShapeForm form = new AddShapeForm();
            form.ShowDialog();
            if (form.SelectedShape != null)
            {
                ModelCell cell = new ModelCell();
                Model model = ComponentFactory.CreateModel(modelCounter + 1);
                modelCounter++;
                model.AddInnerComponent(ComponentFactory.CreateSpacerContainer(form.SelectedShape.GetDxfContours(), form.SpacerWidth, ""));
               // model.AddInnerComponent(ComponentFactory.CreateSpacer(form.SelectedShape.GetDxfContours()[0], form.SpacerWidth, ""));
                cell.AddInnerComponent(model);
                cellRepository.AddCell(cell, form.HorizontalIndex, form.VerticalIndex);
                listBoxShapes.Items.Add(form.SelectedShape);
            }
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            //ShprossMainForm mainForm = new ShprossMainForm(this.GetModelContainer);
            //this.Visible = false;
            //mainForm.ShowDialog();
            //this.Close();
            
        }

        //public ModelContainer GetModelContainer()
        //{
        //    return container;
        //}
    }
}
